package xyz.zdsoft.project_group_manage_module.controller;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RestController;
import xyz.zdsoft.common.utils.Result;
import xyz.zdsoft.project_group_manage_module.service.InsertTeamGchService;
import xyz.zdsoft.project_group_manage_module.service.TermSelTeamGService;
import javax.annotation.Resource;
import java.util.HashMap;

@RestController
@Api(tags = "项目组管理")
public class AdminInsertTeamController {
    @Resource
    private InsertTeamGchService insertTeamGchService;
    @Resource
    private TermSelTeamGService termSelTeamGService;
    @ApiOperation("新增项目组")
    @PostMapping("/InsertTeam")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "teamName",value = "项目组名",required = true,example = "JAVA小组"),
            @ApiImplicitParam(name = "isGraduation",value = "是否结业(0：未结业,1:已结业)",required = true)
    })
    public Result insertTeam(String teamName, String isGraduation){
        HashMap<String,Object> map=new HashMap<>();
        map.put("teamName",teamName);
        termSelTeamGService.TermSelTeam(map);//查询项目组名是否存在
        if (0==termSelTeamGService.TermSelTeam(map).size()){
            map.put("isGraduation",isGraduation);
            return Result.ok().message("新增成功").data(insertTeamGchService.insertTeam(map));
        }
        else  return Result.error().message("项目组已存在");

    }
}
